<%@ Language=VBScript%>
<%
	Session("FormName")="F24"
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Theo doi hoi bao</title>
<!--#include file="..\jvGrid.inc"-->
<!--#include file="..\pageSelected.inc"-->
<%	
	back=request("back")+1
	mode=Request("mode")
	bComm=Request("bComm")
	bMa=Request("bMa")
	bMacu=Request("bMacu")
	bTen=Request("bTen")
	bTencu=Request("bTencu")
	bnguoitao=Session("bHoten")
	bManguoitao=Session("bMaCB")
	bngaytao=request("bNgaytao")
'	Loaitim=request("Loaitim")
	bsearch=Request("bsearch")
	bcallfrmvtden=Request("bcallfrmvtden")	
	'Chon=request("Chon")
	if bComm="detail" then			
		sSQL="Select * from Vuviec where Ma='" & bMa & "'"
		Set RecDisplay=server.CreateObject("ADODB.Recordset")
		RecDisplay.CursorType=3
		RecDisplay.CacheSize=5
		RecDisplay.Open sSQL,Conn
		if RecDisplay.RecordCount then
			bMa=trim(RecDisplay("Ma"))
			bMacu=trim(RecDisplay("Ma"))
			bTen=trim(RecDisplay("Ten"))
			bTencu=trim(RecDisplay("Ten"))
			bnguoitao=trim(RecDisplay("nguoitao"))
			bManguoitao=trim(RecDisplay("nguoitao"))
			bngaytao=trim(RecDisplay("ngaytao"))
			sSQL="Select hovaten from Canbo Where Macanbo='"& bNguoitao &"'"
			Set RecLayten=server.CreateObject("ADODB.Recordset")
			RecLayTen.CursorType=3
			RecLayten.CacheSize=5
			RecLayten.Open sSQL,Conn
			if RecLayten.RecordCount then
				bnguoitao=trim(RecLayten("Hovaten"))
			end if
		end if
		RecDisplay.Close
		set RecDisplay=nothing
	else
		bMa=Request("bMa")
		bMacu=Request("bMacu")
		bTen=Request("bTen")
		bTencu=Request("bTencu")
		bnguoitao=Session("bHoten")
		bManguoitao=Session("bMaCB")
		bngaytao=request("bNgaytao")
	'	Loaitim=request("Loaitim")
		bsearch=request("bsearch")
		bcallfrmvtden=Request("bcallfrmvtden")	
		Chon=request("Chon")
	end if	
	
	Dim bTempComm
	Dim bMsg
	Dim Msg
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),1)="1" or Session("IsAdmin")then
		Select Case bComm
			Case "add"
				if not KTMa(bMa,bComm) then
					bngaytao=SaveDate(bngaytao)
					sSQL="Insert into Vuviec(ma,ten,ngaytao,nguoitao)values('"& ModiString(bMa) &"','"& modiString(bTen) &"','"& bngaytao &"','"& trim(bManguoitao) &"')"
					Conn.Execute sSQL					
				else
					Msg="T&#234;n &#273;&#227; t&#7891;n t&#7841;i"
					bMsg="ma"
				end if
				
			case "delete"	
				on error resume next
				Conn.BeginTrans	
				sSQL="Delete from vanban_vuviec where mavuviec like '"& Modistring(bma) &"'"
				Conn.Execute sSQL
				sSQL="Delete from vuviec Where ma Like '"& ModiString(bMa) &"'"
				Conn.Execute sSQL
				if Err.number then
					Conn.RollbackTrans
				else
					Conn.CommitTrans
				end if
				Err.Clear
			case "edit"
				if not KTMa(bMa,"edit") then
					'Neu ma thay doi
					if lcase(bmacu)<>lcase(bma) then 
						sSQL="Select * from vanban_vuviec where mavuviec like '"& ModiString(bMacu) &"' "
						Set RecT=Server.CreateObject("ADODB.Recordset")
						RecT.CursorType=3
						RecT.CacheSize=5
						RecT.Open sSQL,Conn
						if RecT.RecordCount>0 then
							Msg="M&#227; &#273;ang &#273;&#432;&#7907;c li&#234;n k&#7871;t kh&#244;ng th&#7875; thay &#273;&#7893;i"
							bMsg="malienket"
						else
							bngaytao=SaveDate(bNgaytao)
							sSQL="Update vuviec set ma='"& ModiString(bma) _
											&"',ten='"& ModiString(bTen) _
											&"',ngaytao='"& bngaytao _
											&"',nguoitao='"& trim(ModiString(bManguoitao)) _
											&"' Where ma Like '" & ModiString(bMacu) & "'"
							Conn.Execute sSQL
						end if
						RecT.Close
						set RecT=nothing			
					else 'neu ma khong thay doi
						bngaytao=Savedate(bngaytao)
						sSQL="Update vuviec set ma='"& ModiString(bma) _
										&"',ten='"& ModiString(bTen) _
										&"',ngaytao='"& bngaytao _
										&"',nguoitao='"& trim(ModiString(bManguoitao)) _
										&"' Where ma Like '" & ModiString(bMacu) & "'"
						Conn.Execute sSQL
					end if
				else
					Msg="M&#227; &#273;&#227; T&#7891;n t&#7841;i"
					bMsg="ma"
				end if
		End Select
	end if
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5
	bsearch=request("TxtTen")		
	select case request("bComm")
		case "search"
			Chon=Request("Chon")
			if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then
			  if Session("IsAdmin") then
					ssql="Select * from vuviec where ten like '%"& modistring(bsearch) & "%' order by ngaytao DESC"
			  else		  					
					ssql="Select * from vuviec where nguoitao like '"& Session("bMaCB") &"' and ten like '%"& modistring(bsearch) & "%' order by ngaytao DESC"
			  end if	
			else
				  ssql="Select * from vuviec where nguoitao like '"& Session("bMaCB") &"' and ten like '%"& modistring(bsearch) & "%' order by ngaytao DESC"
			end if
		case else		
			Loaitim=""
			bsearch=""
			Chon=Request("Chon")
			if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then
				 if Session("IsAdmin") then
				  	ssql="Select * from vuviec order by ngaytao DESC"
				  else				  	
				  	ssql="Select * from vuviec where nguoitao like '"& Session("bMaCB") &"' order by ngaytao DESC"
				  end if
			else
				  ssql="Select * from vuviec where nguoitao like '"& Session("bMaCB") &"' order by ngaytao DESC"
			end if
	end select
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	rec.Open ssql,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if	
%>
<%if Msg<>"" then%>
  <% if bMsg="ma" then %>
			<p align=center><font color=red face="Times New Roman">M&#227; v&#7909; vi&#7879;c: <%=bma%> &#273;&#227; t&#7891;n t&#7841;i</font></p>
   <%end if%>
  <% if bMsg="ten" then %>
			<p align=center><font color=red face="Times New Roman">T&#234;n: <%=bten%> &#273;&#227; t&#7891;n t&#7841;i</font></p>
   <%end if%>
   <% if bMsg="malienket" then %>
			<p align=center><font color=red face="Times New Roman"><%=Msg%></font></p>
   <%end if%>
   
   <% if bMsg="" then %>
			<p align=center><font color=red face="Times New Roman"><%=Msg%></font></p>
   <%end if%>
<%end if%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript.Encode runat=server>
' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y
	Function FormatDate(vDate)
	    If Not IsDate(vDate) Then
	        'MsgBox "Invalid Date"
	        Exit Function
	    End If
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function

	'Chuyen thanh xau tu dau viet hoa
	Function sProper(sStr)
		sStr = sSpace(sStr)
	        ChuHoa = "QWERTYUIOPASDFGHJKLZXCVBNM&#194;&#212;&#416;&#431;?&#208;"
        	ChuThuong = "qwertyuiopasdfghjklzxcvbnm&#226;&#244;&#417;&#432;&#234;&#273;"
	        bDodai = Len(Trim(sStr))
        	If bDodai = 0 Then
	            sProper = ""
        	    Exit Function
	        End If
        	s = Mid(sStr, 1, 1)
	        bChar = Mid(sStr, 1, 1)
        	bPos = InStr(1, ChuThuong, bChar)
	        i = 2
        	If bPos Then
	            bKetqua = bKetqua + Mid(ChuHoa, bPos, 1)
        	Else
	            bKetqua = bKetqua + bChar
        	End If
	        Do While i <= bDodai
        	    bChar = Mid(sStr, i, 1)
	            If Mid(sStr, i - 1, 1) = " " Then
        	        bPos = InStr(1, ChuThuong, bChar)
                	If bPos Then
	                    bKetqua = bKetqua + Mid(ChuHoa, bPos, 1)
        	        Else
                	    bKetqua = bKetqua + bChar
	                End If
        	    Else
                	bPos = InStr(1, ChuHoa, bChar)
	                If bPos Then
        	            bKetqua = bKetqua + Mid(ChuThuong, bPos, 1)
                	Else
	                    bKetqua = bKetqua + bChar
        	        End If
	            End If
        	    i = i + 1
	        Loop
        	sProper = bKetqua
	End Function

	   '***Ham loai bo dau cach thua****
	    Function sSpace(sStr)
    		sStr = Trim(sStr)
		Dodai = Len(sStr)
	    	If Dodai <= 1 Then
	           	sSpace = sStr
	           	Exit Function
        	End If
	    	i = 1
        	Do While i <= Dodai
	           Temp = Mid(sStr, i, 1)
        	   If Temp = " " Then
	           	bKetqua = bKetqua + Temp
	            	Do While Mid(sStr, i, 1) = " "
        	        	i = i + 1
	            	Loop
        	   Else
	           	bKetqua = bKetqua + Temp
        	   	i = i + 1
	           End If
	    	Loop
    		sSpace = bKetqua
	    End Function
	'Loai bo dau "'"
	Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
	End function
	'Kiem tra ma trung
	Function KTMa(bValue,loai)
		KTMa=false
		if loai="add" then
			ssql="Select * from vuviec where Ma like '"& trim(ModiString(bValue)) &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset") 
			RecTemp.Open ssql,Application("StrConn")
			if (not rectemp.BOF) and (not RecTemp.EOF) then
				KTMa=True
			end if
			set RecTemp=nothing
		end if
		if loai="edit" then
			if bMacu<>bValue then
				ssql="Select * from vuviec where Ma like '"& trim(ModiString(bValue)) &"'"
				Set RecTemp=server.CreateObject("ADODB.Recordset") 
				RecTemp.Open ssql,Application("StrConn")
				if (not rectemp.BOF) and (not RecTemp.EOF) then
					KTMa=True
				end if
				set RecTemp=nothing
			end if		
		end if
	End function
	'Kiem tra ten trung
	Function KTTen(bValue,loai)
		KTTen=false
		if loai="add" then
			ssql="Select Ten from vuviec where Ten like '"& trim(ModiString(bValue)) &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset") 
			RecTemp.Open ssql,Application("StrConn")
			if (not rectemp.BOF) and (not RecTemp.EOF) then
				KTTen=True
			end if
			set RecTemp=nothing
		end if
		if loai="edit" then
			if bTencu<>bValue then
				ssql="Select Ten from vuviec where ten like '"& trim(ModiString(bValue)) &"'"
				Set RecTemp=server.CreateObject("ADODB.Recordset") 
				RecTemp.Open ssql,Application("StrConn")
				if (not rectemp.BOF) and (not RecTemp.EOF) then
					KTTen=True
				end if
				set RecTemp=nothing
			end if		
		end if
	End function
	'Kiem tra truoc khi Xoa ban ghi co quan he voi bang khac khong
	Function KTQuanhe(bValue,TableName)
		KTQuanhe=false
	End Function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>
<script language=VBScript.Encode  runat="server">
</script>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ChangePage(){
	strURL=nhom.page.value;
	window.nhom.target="right";
	window.nhom.action=strURL;
	window.nhom.submit();
}

function KTNhap(){
	if (nhom.TxtMa.value==""){
		alert("Bạn cần phải nhập mã");
		nhom.TxtMa.focus();
		return false;
	}
	if(daucach(nhom.TxtMa.value)){
		alert("Mã không cho phép chứa ký tự đặc biệt(',space)");
		nhom.TxtMa.focus();
		return false;
	}
	if (nhom.TxtTen.value==""){
		alert("Bạn cần phải nhập tên");
		nhom.TxtTen.focus();
		return false;
	}
	if (!isDate(nhom.TxtNgayTao.value)){
		alert("Ngày không hợp lệ");
		nhom.TxtNgayTao.focus();
		return false;
	}
	return true;
}
function Row_Click(ma,ten,nguoitao,ngaytao){
	document.nhom.TxtMa.value=ma;
	document.nhom.TxtTen.value=ten;
	document.nhom.TxtNguoitao.value=nguoitao;
	document.nhom.TxtNgayTao.value=ngaytao;
}
function CmdAdd_onclick() {
	nhom.TxtMa.value="";
	nhom.TxtTen.value="";
	nhom.TxtNguoitao.value="<%=Session("bHoten")%>";
	nhom.TxtNgayTao.value="<%=formatdate(Date())%>";
	cmdenable(false);
	Unlockdata();
	nhom.TxtMa.focus();
	nhom.sua.value="2";
}
function cmdenable(bvalue){
	if (bvalue){
		nhom.CmdAdd.disabled= false;
		nhom.CmdDelete.disabled= false;
		nhom.CmdEdit.disabled= false;
		//nhom.CmdTheodoi.disabled=false;
		nhom.CmdSearch.disabled=false;
		nhom.CmdCancel.disabled= true;
		nhom.CmdOK.disabled= true;	
	}
	else {
		nhom.CmdAdd.disabled= true;
		nhom.CmdDelete.disabled= true;
		nhom.CmdEdit.disabled= true;
		//nhom.CmdTheodoi.disabled=true;
		nhom.CmdSearch.disabled=true;
		nhom.CmdCancel.disabled= false;
		nhom.CmdOK.disabled= false;
	}	
		nhom.CmdSearch.value="Tì<u>m</u> kiếm";
}

function CmdCancel_onclick() {
	cmdenable(true);
	nhom.CmdDelete.disabled= true;
	nhom.CmdEdit.disabled= true;
	Lockdata();
	nhom.TxtNgayTao.value="";
	nhom.TxtNguoitao.value="";
	nhom.TxtTen.value="";
	nhom.TxtMa.value=""
}

function Lockdata(){
	nhom.TxtMa.disabled=true;
	nhom.TxtNgayTao.disabled=true;
//	nhom.TxtNguoitao.disabled=true;
	nhom.TxtTen.disabled=true;
}
function Unlockdata(){
	nhom.TxtMa.disabled=false;
	nhom.TxtNgayTao.disabled=false;
//	nhom.TxtNguoitao.disabled=false;
	nhom.TxtTen.disabled=false;
}
function window_onload() {
//	CmdCancel_onclick();	
}	

function CmdExit_onclick() {
//	window.navigate("<%= Session("LastForm")%>");
}
function CmdDelete_onclick() {
	if (nhom.TxtMa.value==""){
		alert("Bạn hãy chọn thông tin cần xoá");
		return ;
	}
	if(!confirm("Bạn có muốn xoá không ?")){
		return false;	
	}
	ma=nhom.TxtMa.value;
	cp=nhom.cPage.value;
	<%if bcallfrmvtden="ok" then%>
		b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&bcallfrmvtden=ok&back="+<%=back%>+"&Page="+cp+"&bma="+ma+"&bComm=delete";
	<%else%>
		b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&back="+<%=back%>+"&Page="+cp+"&bma="+ma+"&bComm=delete";										
	<%end if%>
	window.nhom.target="right";
	window.nhom.action=b;
	window.nhom.submit();
}
function CmdEdit_onclick() {
	if (nhom.TxtMa.value==""){
		alert("Bạn hãy chọn thông tin cần sửa");
		return ;
	}
	nhom.CmdTheodoi.disabled=true;
	cmdenable(false);
	Unlockdata();
	nhom.TxtMa.focus();
	<%bTempComm="edit"%>
	nhom.sua.value="1";
	nhom.Macu.value=nhom.TxtMa.value;
	nhom.Tencu.value=nhom.TxtTen.value
}
function CmdOK_onclick() {
	if (KTNhap()){
		cmdenable(true);
		Lockdata();
		ma=nhom.TxtMa.value;
		ten=nhom.TxtTen.value;
		ngaytao=nhom.TxtNgayTao.value;
		nguoitao=nhom.TxtNguoitao.value;
		macu=nhom.Macu.value;
		tencu=nhom.Tencu.value;
		bc=nhom.sua.value;
		cp=nhom.cPage.value;
		if (bc=="1"){
			<%if bcallfrmvtden="ok" then%>
				b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&bcallfrmvtden=ok&back="+<%=back%>+"&Page="+cp+"&bMacu="+macu+"&bTencu="+tencu+"&bma="+ma+"&bTen="+ten+"&bngaytao="+ngaytao+"&bnguoitao="+nguoitao+"&bComm=edit";
			<%else%>
				b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&back="+<%=back%>+"&Page="+cp+"&bMacu="+macu+"&bTencu="+tencu+"&bma="+ma+"&bTen="+ten+"&bngaytao="+ngaytao+"&bnguoitao="+nguoitao+"&bComm=edit";				
			<%end if%>
			//window.nhom.action="frmvuviec.asp?Page="+cp+"&bComm=edit";
			//window.nhom.submit();
		}
		if(bc=="2") {
			<%if bcallfrmvtden="ok" then%>
				b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&bcallfrmvtden=ok&back="+<%=back%>+"&Page="+cp+"&bma="+ma+"&bTen="+ten+"&bngaytao="+ngaytao+"&bnguoitao="+nguoitao+"&bComm=add";
			<%else%>
				b="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&back="+<%=back%>+"&Page="+cp+"&bma="+ma+"&bTen="+ten+"&bngaytao="+ngaytao+"&bnguoitao="+nguoitao+"&bComm=add";																		
			<%end if%>
			//window.nhom.action="frmvuviec.asp?Page="+cp+"&bComm=add";
			//window.nhom.submit();
		}
		window.nhom.target="right";
		window.nhom.action=b;
		window.nhom.submit();
	}
}
function CmdLoc_onclick() {
	Unlockdata();
	nhom.TxtMa.focus();
//	nhom.sua.value="2";
}


function CmdTheodoi_onclick() {
	if(nhom.TxtMa.value==""){
		alert("Bạn phải chọn vụ việc cần theo dõi");
		return false;
	}	
	//window.nhom.target="main";
	window.nhom.target="right";
	parent.vbalFrameset.cols = "0,6,*";
	bmavv=nhom.TxtMa.value;
	window.nhom.action="theodoivuviec/frmtheodoi.asp?bTenVV="+nhom.TxtTen.value+"&bMavv="+nhom.TxtMa.value;
	window.nhom.submit();
}
	

function window_onload() {
	
}

function TxtSearch_onclick() {
}

function CmdSearch_onclick() {
	nhom.CmdAdd.disabled=true;
	nhom.CmdCancel.disabled=false;
	nhom.CmdEdit.disabled=true;
	nhom.CmdDelete.disabled=true;
	nhom.CmdTheodoi.disabled=true;	
	if (nhom.TxtTen.disabled){
		nhom.CmdSearch.value="Tì<u>m</u>";
		Unlockdata();
		nhom.TxtMa.value="";
		nhom.TxtNgayTao.value="";
		nhom.TxtNguoitao.value="";
		nhom.TxtTen.value="";
		Lockdata();
		nhom.TxtTen.disabled=false;
		nhom.TxtTen.value="";
		nhom.TxtTen.focus();
		return false;
	}
	value=nhom.TxtTen.value;
	<%if bcallfrmvtden="ok" then%>
		blink="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&bcallfrmvtden=ok&back="+<%=back%>+" &bsearch="+value+"&bComm=search";
	<%else%>
		blink="frmvuviec.asp?Chon="+"<%=request("Chon")%>"+"&back="+<%=back%>+"&bsearch="+value+" &bComm=search";
	<%end if%>
	window.nhom.action=blink;
	window.nhom.target="right"
	window.nhom.submit();

}

function CmdQuaylai_onclick(){
	history.go(-<%=back%>);
}
/*function CmdOne_onclick() {
	  nhom.target="right";
	  nhom.action="frmvuviec.asp?Chon=one";
	  nhom.submit();
}*/

/*function CmdAll_onclick() {
	  nhom.target="right";
	  nhom.action="frmvuviec.asp?Chon=all";
	  nhom.submit();
}*/

function TxtNgaytao_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	nhom.TxtNgayTao.value=editdate(trim(str))
}
}

function SetFocus(){
	document.nhom.CmdSearch.focus();
}
//-->
</SCRIPT>
</head>
<body  bgcolor=#F8F9D9 leftmargin=2 topmargin=0 style="FONT-FAMILY:Times New Roman" onload="SetFocus()">
<form name="nhom" method="post" >

	<%if bcallfrmvtden="ok" then%>
  		<input type="hidden" name="sua" value="2">
  	<%else%>
  		<input type="hidden" name="sua" value="">
  	<%end if%>
	<input type="hidden" name="Macu" value="">
	<input type="hidden" name="Tencu" value="">
	<input type="hidden" name="cPage" value="<%=nPage%>">
	<input type="hidden" name="strURL" value="">
<table border="0" width="100%" bgcolor="#bdd5d0" cellspacing=1 cellpadding=0>
	<tr>
		<td bgcolor="#173584" ALIGN="CENTER" colspan=7><FONT COLOR=WHITE FACE="Arial" SIZE=2>THEO D&#213;I H&#7890;I B&#193;O</FONT></td>
	</tr>
    <tr>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),1)="1" or  Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then %>
				<%if Request("Chon")="all" then%>
				  <td width="14%"><Button name="CmdAdd" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
				  <%if bComm<>"detail" then%>
					  <td width="14%"><Button name="CmdDelete" disabled=true style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					  <td width="14%"><Button name="CmdEdit" disabled=true style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				  <%else%>
					<%if bMatao<>Session("bMaCB") then%>
						<td width="14%"><Button disabled name="CmdDelete"  style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
						<td width="14%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
					<%else%>
						<td width="14%"><Button name="CmdDelete"  style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
						<td width="14%"><Button name="CmdEdit" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
					<%end if%>
				  <%end if%>
					  <td width="14%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%else%>
					  <td width="14%"><Button name="CmdAdd" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
				  <%if trim(bMa)="" then%>
					  <td width="14%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					  <td width="14%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				  <%else%>  
					 <td width="14%"><Button name="CmdDelete" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					  <td width="14%"><Button name="CmdEdit" style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
				  <%end if%>
					  <td width="14%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%end if%>
					<td width="14%"><Button name="CmdCancel" disabled=true style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
					<td width="16%"><Button name="CmdSearch" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
				<%if bcallfrmvtden="ok" then%>
					<td width="16%"><Button name="CmdQuaylai" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdQuaylai_onclick()" accesskey="Y"><p>Qua<u>y</u> lại</p></Button></td>
				<%else%>
					<%if bcomm<>"detail" then%>
						<td width="16%"><Button disabled name="CmdTheodoi" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdTheodoi_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
					<%else%>
						<td width="16%"><Button name="CmdTheodoi" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdTheodoi_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
					<%end if%>
				<%end if%>
				<%else%>
					<td width="14%"><Button name="CmdAdd" disabled=true style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
					<td width="14%"><Button name="CmdDelete" disabled=true style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
					<td width="14%"><Button name="CmdEdit" disabled=true style="FONT-FAMILY: Arial; LEFT: 0px; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
					<td width="14%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
					<td width="14%"><Button name="CmdCancel" disabled=true style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
					<td width="16%"><Button name="CmdSearch" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
					<%if bcomm<>"detail" then%>
						<td width="16%"><Button disabled name="CmdTheodoi" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdTheodoi_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
					<%else%>
						<td width="16%"><Button name="CmdTheodoi" style="FONT-FAMILY: Arial; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdTheodoi_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
					<%end if%>
			<%end if%>			
        </tr>
</table>
<!-- Form nhap lieu -->
<table border="0" bgcolor="#bdd5d0" width="100%" cellspacing="0" cellpadding="0">
<% if bcomm="detail" then %>
	  <tr>
	     <td width="15%">M&#227; v&#7909; vi&#7879;c</td>
	    <td width="35%">
        <input name="TxtMa" disabled=true value="<%=bma%>" maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	    <td width="15%" align=center>Ng&#432;&#7901;i t&#7841;o</td>
	    <td width="35%">
        <input name="TxtNguoitao" disabled=true value="<%=bNguoitao%>" maxLength=50 style="FONT-FAMILY:Arial;width:100%" size="20"></td>
	  </tr>
	  <tr>
	    <td width="15%">T&#234;n v&#7909; vi&#7879;c</td>
	    <td width="35%">
        <input name="TxtTen" disabled=true maxLength=100 value="<%=bten%>" style="FONT-FAMILY:Arial;width:100%" size="20"></td>
	    <td width="15%" align=center>Ng&#224;y t&#7841;o</td>
	    <td width="35%">
        <input name="TxtNgayTao" maxLength=10 disabled=true value="<%=formatdate(bngaytao)%>" style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtNgaytao_onkeyup(this.value)" size="20"></td>
	  </tr>
<%else%>
	 </tr>
		  <td width="15%">M&#227; v&#7909; vi&#7879;c</td>
		  <td width="35%">
          <input name="TxtMa" disabled=true maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
		  <td width="15%" align=center>Ng&#432;&#7901;i t&#7841;o</td>
		  <td width="35%">
          <input name="TxtNguoitao" maxLength=50 disabled=true style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	</tr>
	<tr>
		  <td width="15%">T&#234;n v&#7909; vi&#7879;c</td>
		  <td width="35%">
          <input name="TxtTen" disabled=true maxLength=100 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
		  <td width="15%" align="center">Ng&#224;y t&#7841;o</td>
		  <td width="35%">
          <input name="TxtNgayTao" maxLength=10 disabled=true style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtNgaytao_onkeyup(this.value)" size="20"></td>
	</tr>
<%end if%>
</table>

<!-- <Div align=center>
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then%>
		<%if request("Chon")="all" then%>
			<input type="radio" ID=R2 value=2  name =one LANGUAGE=javascript onclick="return CmdOne_onclick()"><label for=R2 accesskey="u">Theo dõi v<u>ụ</u> việc cá nhân</label>
			<input type="radio" ID=R1 value=1 checked name=all LANGUAGE=javascript onclick="return CmdAll_onclick()"><label for=R1 accesskey="a">Theo dõi t<u>ấ</u>t cả các vụ việc</label>
		<%else%>
			<input type="radio" ID=R2 value=2 checked name =one LANGUAGE=javascript onclick="return CmdOne_onclick()"><label for=R2 accesskey="u">Theo dõi v<u>ụ</u> việc cá nhân</label>
			<input type="radio" ID=R1 value=1  name=all LANGUAGE=javascript onclick="return CmdAll_onclick()"><label for=R1 accesskey="a">Theo dõi t<u>ấ</u>t cả các vụ việc</label>
		<%end if%>
	<%end if%>
</div> -->
<!-- Danh sach vu viec -->
<table  border="0" width="100%" style="Border-color:#C0C0C0;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid">
  <tr>
	<td width="100%" colspan="3" bgcolor="#173584" ALIGN="CENTER"><FONT COLOR=WHITE FACE=Arial SIZE=2>DANH S&#193;CH V&#7908; VI&#7878;C</FONT>
    </td>
  </tr>
  <tr bgcolor="#bdd5d0">
    <td width="15%" align="center">M&#227;</td>
    <td width="65%" align="center">T&#234;n</td>
    <td width="20%" align="center">Ng&#224;y t&#7841;o</td>      
  </tr>
<%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
%>  
  <tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>" 
 onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
    <td width="15%" height="1"><a style='cursor:hand;color:blue;text-decoration: none' href="frmvuviec.asp?Chon=<%=Chon%>&bComm=detail&page=<%=nPage%>&bma=<%=Rec("ma")%>"><%=Rec("ma")%></a></td>
    <td width="65%" height="1"><a style='cursor:hand;color:blue;text-decoration: none' href="frmvuviec.asp?Chon=<%=Chon%>&bComm=detail&page=<%=nPage%>&bma=<%=Rec("ma")%>"><%=Rec("ten")%></a></td>
    <td width="20%" height="1" align=center><a style='cursor:hand;color:blue;text-decoration: none' href="frmvuviec.asp?Chon=<%=Chon%>&bComm=detail&page=<%=nPage%>&bma=<%=Rec("ma")%>"><%=formatdate(Rec("ngaytao"))%></a></td>
  </tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
	end if
	rec.Close
	set rec=nothing
	
%>  
</table>
 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
					strURL="frmvuviec.asp?Chon="& Chon &"&bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm="
				else
					strURL="frmvuviec.asp?Chon="& Chon &"&bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm=search"
				end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %> -->             
<% 'else %>
<% end if %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
  </tr>
</table>
</body>
</form>
</html>
<%
	Conn.Close
	set conn=nothing
%>